/*!
 * \file frthrift_json_get_type.c
 *
 * All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.\n
 *
 * \version 3.0
 * \author geyh
 * \date 2017/03/07
 *
 */

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"
#include "conntrack.h"
#include "frct_comm.h"
#include "frbyte_buffer.h"
#include "frreport_comm.h"
#include "../../../src/module/json/config.h"
#include "../../../src/module/json/json_data_analyze.h"
#include "../../../src/module/json/json_comm.h"

#include "apmtest_cunit.h"
#include "apmtest_comm.h"

#define MC_STOP     0
#define MC_VOID     1
#define MC_BOOL     2
#define MC_BYTE     3
#define MC_DOUBLE   4
#define MC_I16      6
#define MC_I32      8
#define MC_I64      10
#define MC_STRING   11
#define MC_STRUCT   12
#define MC_MAP      13
#define MC_SET      14
#define MC_LIST     15
#define MC_ENUM     16

static int __suite_init(void)
{

    return 0;
}

static int __suite_cleanup(void)
{

    return 0;
}

extern uint8_t frthrift_json_get_type(const char *p_type_name);

static void case1(void)
{
    const char *p_type_name = "double";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_DOUBLE);

}

static void case2(void)
{
    const char *p_type_name = "i8";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_BYTE);

}


static void case3(void)
{
    const char *p_type_name = "i16";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_I16);

}

static void case4(void)
{
    const char *p_type_name = "i32";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_I32);

}

static void case5(void)
{
    const char *p_type_name = "lst";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_LIST);

}

static void case6(void)
{
    const char *p_type_name = "map";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_MAP);

}

static void case7(void)
{
    const char *p_type_name = "true";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_BOOL);

}


static void case8(void)
{
    const char *p_type_name = "true";
    uint8_t u8_type = 0;

    u8_type = frthrift_json_get_type(p_type_name);

    CU_ASSERT_EQUAL(u8_type, MC_BOOL);

}


int add_suite_frthrift_json_get_type(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" frthrift_json_get_type()", __suite_init, __suite_cleanup)) == NULL)
    return FR_FAIL;

    CU_add_test(pSuite, "case1", case1);
    CU_add_test(pSuite, "case2", case2);
    CU_add_test(pSuite, "case3", case3);
    CU_add_test(pSuite, "case4", case4);
    CU_add_test(pSuite, "case5", case5);
    CU_add_test(pSuite, "case6", case6);
    CU_add_test(pSuite, "case7", case7);
    CU_add_test(pSuite, "case8", case8);


    return FR_SUCC;

}